<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="s"  uri="/struts-tags"%>
<%@ taglib prefix="p" uri="/WEB-INF/page_qidi.tld"%> 
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%
 	String path = request.getContextPath();
 	String basePath = request.getScheme() + "://"
 			+ request.getServerName() + ":" + request.getServerPort()
 			+ path + "/";
 %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>管理公告通知</title>
<link type="text/css" rel="stylesheet" href="http://img.xxt.m-school.cn/wisdom/style/style.css">
<script type="text/javascript" language="javascript" src="http://img.xxt.m-school.cn/wisdom/js/mode.js"></script>
<script type="text/javascript" language="javascript" src="http://img.xxt.m-school.cn/wisdom/js/tableList.js"></script>
<script type='text/javascript'
			src='${pageContext.request.contextPath}/dwr/interface/examDwr.js'></script>
		<script type='text/javascript'
			src='${pageContext.request.contextPath}/dwr/engine.js'></script>
		<script type='text/javascript'
			src='${pageContext.request.contextPath}/dwr/util.js'></script>
<script type="text/javascript">
function getExamClass(Str) {
	var njid = document.getElementById('examnj').value;
	njcode = njid;
	examDwr.queryIsSelectClass(njcode,Str, classcheck);
}

function classcheck(data) {
	var setExamClass = document.getElementById("examclass");
	var htmlcode = "<table width='100%' border='0' cellpadding='0' cellspacing='1' class='comBodyStyle'><tr>";
	if (null != data && "" != data) {
		for (i = 0; i < data.length; i++){
			if((i+1)==1){
				htmlcode+="<tr><td align='center' bgcolor='#e9f1fc'><table border='0' cellspacing='0' cellpadding='0'><tr><td>";
				if("Y"==data[i].isSelect){
					htmlcode+="<td><input type='checkbox' name='ksbjcode' value='"+data[i].classCode+"' checked='checked'></td>";
				}else{
					htmlcode+="<td><input type='checkbox' name='ksbjcode' value='"+data[i].classCode+"'></td>";
				}
				htmlcode+="<td>"+data[i].className+"</td></tr></table></td>";
			}else if((i+1)%6==0){
				htmlcode+="<td align='center' bgcolor='#e9f1fc'><table border='0' cellspacing='0' cellpadding='0'><tr><td>";
				if("Y"==data[i].isSelect){
					htmlcode+="<td><input type='checkbox' name='ksbjcode' value='"+data[i].classCode+"' checked='checked'></td>";
				}else{
					htmlcode+="<td><input type='checkbox' name='ksbjcode' value='"+data[i].classCode+"'></td>";
				}
				htmlcode+="<td>"+data[i].className+"</td></tr></table></td></tr><tr>";
			}else{
				htmlcode+="<td align='center' bgcolor='#e9f1fc'><table border='0' cellspacing='0' cellpadding='0'><tr><td>";
				if("Y"==data[i].isSelect){
					htmlcode+="<td><input type='checkbox' name='ksbjcode' value='"+data[i].classCode+"' checked='checked'></td>";
				}else{
					htmlcode+="<td><input type='checkbox' name='ksbjcode' value='"+data[i].classCode+"'></td>";
				}
				htmlcode+="<td>"+data[i].className+"</td></tr></table></td>";
			}
		}
	}
	htmlcode+="</tr></table>";
	setExamClass.innerHTML = htmlcode;
}

function submitForm(){
		var temp = 0;
		if(document.getElementById('exnameTemp').value==""){
			alert("请填写考试日程名称！");
			return false;
		}
		if(document.getElementById('exkssjTemp').value==""){
			alert("请填写考试开始时间！");
			return false;
		}
		if(document.getElementById('exjssjTemp').value==""){
			alert("请填写考试结束时间！");
			return false;
		}
		
		if(opinionTime(document.getElementById('exkssjTemp').value,document.getElementById('exjssjTemp').value)){
			alert("请填写正确的考试时间，结束时间必须后于开始时间！");
			return false;
		}
        
		
		var smObj = document.getElementsByName("checkKm");
            for (var i = 0; i < smObj.length; i++){
            	if(smObj[i].checked){
            		temp = 1;
            		break;
            	}
	    }
	    
	    if(temp==0){
	    	alert("请选择考试科目！");
			return false;
	    }
	    temp=0;
	    var smObj = document.getElementsByName("ksbjcode");
            for (var i = 0; i < smObj.length; i++){
            	if(smObj[i].checked){
            		temp = 1;
            		break;
            	}
	    }
	    
	    if(temp==0){
	    	alert("请选择考试班级！");
			return false;
	    }
	    
		document.getElementById('queryAll').click();
}

function opinionTime(stratTime,endTime){
        var start = stratTime.split( "-" );
        var end = endTime.split( "-" );
        if(start[0]<=end[0]){
              if(start[0] == end[0]){
                   if(start[1]<=end[1]){
                   if(start[1] ==end[1]){
                 if(start[2]<=end[2]){
                    return false;
                  }else
                           return true;
                    }else
                      return false;
                     }else
                          return true;
                }else
                     return false;
           }else
               return true;
     }

</script>
</head>

<body class="conBody" onLoad="infoSrcoll()" onResize="infoSrcoll()">
<form action="examAction!updateSuccess" method="post">
<table width="100%" height="100%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td align="left" valign="top">
	<div id="infoSrcoll">
	<table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td class="bodylist"><table border="0" cellspacing="0" cellpadding="0" class="topSelectStyle">
      <tr>
        <td>考试名称：</td>
        <td class="bodyBlock"><input type="text" id="exnameTemp" name="exnameTemp" class="comInputStyle" value="${requestScope.exam.examName}"></td>
        <td>考试类别：</td>
        <td class="bodyBlock"><select name="exlbTemp" class="comInputStyle">
        <option <s:if test="%{#request.exam.kslbm==1}">selected="selected"</s:if> value="1">大考</option>
        <option <s:if test="%{#request.exam.kslbm==2}">selected="selected"</s:if> value="2">年级考试</option>
        <option <s:if test="%{#request.exam.kslbm==3}">selected="selected"</s:if> value="3">测验（小考）</option>
        </select></td>
      </tr>
      <tr>
      <td>开始时间：</td>
        <td class="bodyBlock"><input type="text" id="exkssjTemp" name="exkssjTemp" class="comInputStyle" onClick="WdatePicker({skin:'whyGreen'})" value="${requestScope.exam.examBeginTime}"/></td>
        <td>结束时间：</td>
        <td class="bodyBlock"><input type="text" id="exjssjTemp" name="exjssjTemp" class="comInputStyle" onClick="WdatePicker({skin:'whyGreen'})" value="${requestScope.exam.examEndTime}"/></td>
        <td><input type="submit" id="queryAll" style="display: none;"/></td>
      </tr>
    </table></td>
      </tr>
      <tr>
        <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td class="bodyCovTitle">考试科目：</td>
          </tr>
          <tr>
            <td><table width="100%" border="0" cellspacing="0" cellpadding="0" id="mainTbody" class="listTopBg">
              <tr>
              <s:iterator value="#request.schoolKm"  id="km">
                <th class="thCenter"><s:property value="kmname"/></th>
              </s:iterator>
              </tr>
              <tr onMouseOver="this.className = 'tronMouseover'" onMouseOut="this.className = 'tronMouseout'" class="tronMouseout">
                <s:iterator value="#request.schoolKm"  id="km">
                <s:if test='%{#km.isselect=="Y"}'>
                <td align="center"><input name="checkKm"  type="checkbox" value="<s:property value="kmcode"/>" checked="checked"></td>
                </s:if>
                <s:else>
                <td align="center"><input name="checkKm"  type="checkbox" value="<s:property value="kmcode"/>"></td>
                </s:else>
                
                </s:iterator>
              </tr>
              <tr onMouseOver="this.className = 'tronMouseover'" onMouseOut="this.className = 'tronMouseout'" class="tronMouseout">
                <s:iterator value="#request.schoolKm"  id="km">
                <td align="center"><select name="ksfz">
                <option <s:if test='%{#km.isselect=="Y"&&#km.kmfzcode==1}'>selected="selected"</s:if> value="<s:property value="kmcode"/>:1">100分制</option>
                <option <s:if test='%{#km.isselect=="Y"&&#km.kmfzcode==2}'>selected="selected"</s:if> value="<s:property value="kmcode"/>:2">120分制</option>
                <option <s:if test='%{#km.isselect=="Y"&&#km.kmfzcode==3}'>selected="selected"</s:if> value="<s:property value="kmcode"/>:3">150分制</option>
                </select></td>
                </s:iterator>
              </tr>
            </table></td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td><table border="0" cellspacing="0" cellpadding="0">
			  <tr>
				<td class="bodyCovTitle">考试对象：</td>
				<td valign="bottom"><table border="0" cellspacing="0" cellpadding="0">
                  <tr>
                    <td>年级：</td>
                    <td><span class="bodyBlock">
                      <select id="examnj" name="examnj" class="comInputStyle" onchange="getExamClass('${requestScope.exam.examId}')">
                      <s:iterator value="#request.schoolNj"  id="nj">
                      <s:if test="%{#request.dmNjcode==#nj.gradeId}">
                      	<option value="<s:property value="gradeId"/>" selected="selected"><s:property value="gradeName"/></option>
                      </s:if>
                      <s:else>
                      	<option value="<s:property value="gradeId"/>"><s:property value="gradeName"/></option>
                      </s:else>
                      </s:iterator>
                      </select>
                      
                    </span></td>
                    </tr>
                </table></td>
				</tr>
			</table>
			</td>
          </tr>
          <tr>
            <td id="examclass">
                <table width="100%" border="0" cellpadding="0" cellspacing="1" class="comBodyStyle">
              
              
              <s:iterator value="#request.listSelectBj"  id="ksbj" status="pageindex">
              <s:if test="%{#pageindex.count==1}">
              <tr>
              <td align="center" bgcolor="#e9f1fc"><table border="0" cellspacing="0" cellpadding="0">
                  <tr>
                  <s:if test='%{#ksbj.isSelect=="Y"}'>
                    <td><input type="checkbox" name="ksbjcode" value="<s:property value="classCode"/>" checked="checked"></td>
                  </s:if>
                  <s:else>
                  	<td><input type="checkbox" name="ksbjcode" value="<s:property value="classCode"/>"></td>
                  </s:else>
                    <td><s:property value="className"/></td>
                  </tr>
                </table></td>
              </s:if>
              <s:elseif test="%{#pageindex.count%6==0}">
              <td align="center" bgcolor="#e9f1fc"><table border="0" cellspacing="0" cellpadding="0">
                  <tr>
                  <s:if test='%{#ksbj.isSelect=="Y"}'>
                    <td><input type="checkbox" name="ksbjcode" value="<s:property value="classCode"/>" checked="checked"></td>
                  </s:if>
                  <s:else>
                  	<td><input type="checkbox" name="ksbjcode" value="<s:property value="classCode"/>"></td>
                  </s:else>
                    <td><s:property value="className"/></td>
                  </tr>
                </table></td>
                </tr><tr>
              </s:elseif>
              <s:else>
              <td align="center" bgcolor="#e9f1fc"><table border="0" cellspacing="0" cellpadding="0">
                  <tr>
                  <s:if test='%{#ksbj.isSelect=="Y"}'>
                    <td><input type="checkbox" name="ksbjcode" value="<s:property value="classCode"/>" checked="checked"></td>
                  </s:if>
                  <s:else>
                  	<td><input type="checkbox" name="ksbjcode" value="<s:property value="classCode"/>"></td>
                  </s:else>
                    <td><s:property value="className"/></td>
                  </tr>
                </table></td>
              </s:else>
              
              </s:iterator>  
               </tr> 
              
            </table>
     
                </td>
          </tr>
        </table></td>
      </tr>
    </table>
	</div>
	</td>
  </tr>
  <tr>
    <td height="50" id="buttonCov"><table border="0" cellspacing="0" cellpadding="0">
      <tr>
      <s:if test='%{#request.pagetype!="look"}'>
		<td class="buttonOut">
		<table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td class="buttonLeft"></td>
            <td class="buttonCenter" onMouseDown="buttonDown(this)" onMouseOver="buttonOver(this)" onMouseOut="buttonOut(this)">
			<a href="#" onclick="submitForm()">确定修改</a>
			</td>
            <td class="buttonRight"></td>
          </tr>
        </table>
		</td>
		</s:if>
		<td class="buttonOut">
		<table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td class="buttonLeft"></td>
            <td class="buttonCenter" onMouseDown="buttonDown(this)" onMouseOver="buttonOver(this)" onMouseOut="buttonOut(this)">
			<s:a href="javascript:history.go(-1);">返回列表</s:a>
			</td>
            <td class="buttonRight"></td>
          </tr>
        </table>
		</td>
      </tr>
    </table></td>
  </tr>
</table>
	<input type="hidden" name="total" value="${requestScope.pageVo.total}"/>
	<input type="hidden" name="currentPage" value="${requestScope.pageVo.currentPage}"/>
	<input type="hidden" name="condition" value="${requestScope.pageVo.condition}"/>
	<input type="hidden" name="exid" value="${requestScope.exam.examId}"/>
</form>
<script language="javascript" src="http://img.xxt.m-school.cn/wisdom/js/DatePicker/WdatePicker.js" type="text/javascript"></script>
</body>
</html>
